package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.userInfo.entity.GiveLikeMessage;
import com.rongshu.view.userInfo.iview.GiveLikeView;

import rx.Subscriber;

public class GiveLikePresenter extends BasePresenter<GiveLikeView> {

    public GiveLikePresenter(Context context) {
        super(context);
    }

    /**
     * 点赞消息
     */
    public void getLikeMsg(int user_id, int pageIndex, int pageSize, String sign) {
        RetorfitService.getLikeMsg(user_id, pageIndex, pageSize, sign)
                .compose(getView().<GiveLikeMessage>bindToLife())
                .subscribe(new Subscriber<GiveLikeMessage>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(GiveLikeMessage giveLikeMessage) {
                        if (getView() != null) {
                            getView().onGiveLikeMsg(giveLikeMessage);
                        }
                    }
                });
    }
}
